<%@ page import="com.xinjie.www.util.Constants" %>
<%@ page import="com.xinjie.www.po.User" %>
<%@ page import="com.xinjie.www.service.thumb.ThumbServiceImpl" %>
<%@ page import="com.xinjie.www.po.Thumb" %>
<%@ page import="java.util.List" %>
<%@ page import="java.sql.SQLException" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>点赞列表</title>
    <style type="text/css">
        table {
            width: 100%;
            border: 1px solid red;
            border-collapse: collapse;
        }

        th, td {
            border: 1px solid red;
        }
    </style>
</head>
<body>
<%
    Object o = request.getSession().getAttribute(Constants.USER_SESSION);
    User user = (User) o;
    ThumbServiceImpl thumbService = new ThumbServiceImpl();
    List<Thumb> thumbs = null;
    try {
        thumbs = thumbService.getThumb(user.getUserId());
    } catch (SQLException | ClassNotFoundException e) {
        e.printStackTrace();
    }
%>
<div align="center">
    <table>
        <tr>
            <th>点赞id</th>
            <th>帖子id</th>
            <th>点赞时间</th>
            <th></th>
            <th></th>
        </tr>
        <%
            for (Thumb thumb : thumbs) {
        %>
        <tr>
            <%="<td>" + thumb.getThumbId() + "</td>"%>
            <%="<td>" + thumb.getPostId() + "</td>"%>
            <%="<td>" + thumb.getTime() + "</td>"%>
            <%
                int post_id = thumb.getPostId();
                int thumb_id = thumb.getThumbId();
            %>
            <td><a href="ThumbPost.jsp?postId=<%=post_id%>">查看该帖子</a></td>
            <td><a href="CancelThumb.jsp?thumbId=<%=thumb_id%>&postId=<%=post_id%>">取消点赞</a></td>
        </tr>
        <%}%>
    </table>
    <a href="UserFrame.jsp">返回</a>
    <%if (request.getSession().getAttribute("CancelThumbSuccess") != null) {%>
    <%=request.getSession().getAttribute("CancelThumbSuccess")%>
    <%request.getSession().removeAttribute("CancelThumbSuccess");%>
    <%
        }
        if (request.getSession().getAttribute("CancelThumbLose") != null) {
    %>
    <%=request.getSession().getAttribute("CancelThumbLose")%>
    <%request.getSession().removeAttribute("CancelThumbLose");%>
    <%}%>
</div>
</body>
</html>
